/**
 * Author:   e20160504
 * Date:     2018/7/6 14:23
 * Description:
 */
package com.kevin.demo.test;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;
import com.kevin.demo.entity.user.User;
import com.kevin.demo.service.base.BaseService;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class test {

    @Autowired
    private static BaseService<User> baseService;
    //
    //private static String[] types = {"java.lang.Integer",
    //        "java.lang.Double",
    //        "java.lang.Float",
    //        "java.lang.Long",
    //        "java.lang.Short",
    //        "java.lang.Byte",
    //        "java.lang.Boolean",
    //        "java.lang.Character",
    //        "java.lang.String",
    //        "int","double","long","short","byte","boolean","char","float"};
    //
    public static void main(String[] args) throws IOException, URISyntaxException {

        Map<String,String> map = Maps.newHashMap();

        map.remove("a");
        System.out.println(map);


    }
    //    test test = new test();
    //    test.showURL();

        //URI uri = new URIBuilder("http://www.baidu.com/s").setParameter("wd", "java").setParameter("name","keivn").build();
        //System.out.println(uri);


    //    Map<String,Object> param = Maps.newHashMap();
    //    param.put("name","kevin");
    //    param.put("age",20);
    //
    //    List<NameValuePair> paramList = new ArrayList<>();
    //    for(String key : param.keySet()){
    //        paramList.add(new BasicNameValuePair(key,String.valueOf(param.get(key))));
    //    }
    //
    //    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
    //
    //    System.out.println(JSON.toJSONString(param));
    //}

    public void showURL() throws IOException {

        // 第一种：获取类加载的根路径   D:\git\daotie\daotie\target\classes
        File f = new File(this.getClass().getResource("/").getPath());
        System.out.println(f);

        // 获取当前类的所在工程路径; 如果不加“/”  获取当前类的加载目录  D:\git\daotie\daotie\target\classes\my
        File f2 = new File(this.getClass().getResource("").getPath());
        System.out.println(f2);

        // 第二种：获取项目路径    D:\git\daotie\daotie
        File directory = new File("");// 参数为空
        String courseFile = directory.getCanonicalPath();
        System.out.println(courseFile);


        // 第三种：  file:/D:/git/daotie/daotie/target/classes/
        URL xmlpath = this.getClass().getClassLoader().getResource("");
        System.out.println(xmlpath);


        // 第四种： D:\git\daotie\daotie
        System.out.println(System.getProperty("user.dir"));
        /*
         * 结果： C:\Documents and Settings\Administrator\workspace\projectName
         * 获取当前工程路径
         */

        // 第五种：  获取所有的类路径 包括jar包的路径
        System.out.println(System.getProperty("java.class.path"));

    }

}
